package com.yxkj.syh.app.huarong.activities.orders.list;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.syh.app.basic.base.view_model.BaseViewModel;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.utils.net.ApiObserver;
import com.trello.rxlifecycle2.android.FragmentEvent;
import com.yxkj.syh.app.huarong.bean.OrderListResponse;
import com.yxkj.syh.app.huarong.bean.PagesRequest;
import com.yxkj.syh.app.huarong.data_center.model.OrderModel;

/**
 * 创建者：SYH
 * 时间：2020/5/20 11:04
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class OrderListVM extends BaseViewModel<FragmentEvent> {


    public OrderListVM(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<OrderListResponse.Data> mldOrderResponse = new MutableLiveData<>();

    public void getOrderList(PagesRequest ordersRequest){
        OrderModel.getOrderModel().orderList(ordersRequest,mLifecycleProvider.bindToLifecycle(), new ApiObserver<OrderListResponse>() {
            @Override
            public void onSuccess(OrderListResponse orderListResponse) {
                mldOrderResponse.setValue(orderListResponse.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
                mldOrderResponse.setValue(null);
            }
        });
    }

}
